﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace N03_11HCA_HTTTHD.Controllers
{
    public class TinTucController : Controller
    {
        Data_DAO_DTO_Lib.TINTUC_DAO tinTucDAO = new Data_DAO_DTO_Lib.TINTUC_DAO();

        //
        // GET: /TimMua/
        public ActionResult Index()
        {
            ViewBag.TK = N03_11HCA_HTTTHD.TienIch.HeThong.LayThongTinTKHienTai(Session);

            List<Data_DAO_DTO_Lib.DTO.DTO> list = tinTucDAO.LayDanhSachCoThamSo(0, TienIch.HeThong.SoLuongLoadTinTucMacDinh, TienIch.HeThong.ChuoiSapXepTinTucMacDinh);
            Models.TinTuc modelTimMua = new Models.TinTuc(list);

            return View("TinTuc", modelTimMua);
        }

        [HttpPost]
        public JsonResult Index(int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
        {
            List<Data_DAO_DTO_Lib.DTO.DTO> list = tinTucDAO.LayDanhSachCoThamSo(jtStartIndex, jtPageSize, jtSorting);

            return new JsonResult() { Data = list };
        }

        public ActionResult ChiTiet(int id_TimMua)
        {
            ViewBag.TK = N03_11HCA_HTTTHD.TienIch.HeThong.LayThongTinTKHienTai(Session);

            Data_DAO_DTO_Lib.DTO.TINTUC_DTO tinTuc = (Data_DAO_DTO_Lib.DTO.TINTUC_DTO)tinTucDAO.LayTuID(id_TimMua);
            Models.TinTuc_ChiTiet modelTinTuc = new Models.TinTuc_ChiTiet(tinTuc);

            return View("TinTuc_ChiTiet", modelTinTuc);
        }

    }
}
